package com.coupon.constrol;



import com.coupon.pojo.Admin;
import com.coupon.service.AdminService;
import com.coupon.util.JsonResult;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Map;
@SuppressWarnings("all")
@Controller
@ResponseBody
@RequestMapping("/admin")
public class AdminController {
    @Resource
    AdminService adminService;
    @RequestMapping("/login")
    public Map login(@RequestParam("phone") String phone,@RequestParam("pwd") String pwd){

        Admin login=adminService.loginAdmin(phone,pwd);
        JsonResult json=new JsonResult();
        if (login!=null)
        {

            System.out.println("登录成功！");
            json.setCode(1);
            json.setData(login);
        }
        else
        {
            System.out.println("账号、密码错误，登录失败！");
            json.setCode(0);
        }
        return json.getValues();
    }
}
